package com.ict.txmsv2.controller.clockIn;

import com.ict.txmsv2.model.*;
import com.ict.txmsv2.services.ClockInService;
import com.ict.txmsv2.services.SumtimeService;
import com.ict.txmsv2.services.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author yoleen
 * @date 2020/12/17 14:28
 */

@RestController
@RequestMapping("/clock/records")
public class ClockRecordsController {
    @Autowired
    UserService userService;
    @Autowired
    ClockInService clockInService;
    @Autowired
    SumtimeService sumtimeService;

    @GetMapping("/")
    @MethodDescrition("根据日期获取打卡记录")
    public List<User> getUsersWithClockInByDay(String day){
        return userService.getUsersWithClockInByDay(day);
    }

    @GetMapping("/commute")
    @MethodDescrition("获取当天每个人的上下班时间")
    public RespPageBean getCommute(String day,@RequestParam(defaultValue = "1") Integer page,
                                   @RequestParam(defaultValue = "6") Integer size){
        return clockInService.getCommuteByDayWithPage(day, page,size);
    }
    
    @GetMapping("/year")
    @MethodDescrition("获取今年每天打卡时长")
    public List<SumTime> getTimeByUserId(Integer userId){
        return sumtimeService.getTimeByUserId(userId);
    }


    @GetMapping("/ym")
    @MethodDescrition("获取年月总时间")
    public RespPageBean getYearMonthSumTime(@RequestParam(defaultValue = "1")Integer page, @RequestParam(defaultValue = "5")Integer size){
        return sumtimeService.getYearMonthSumTime(page,size);
    }
}
